<!DOCTYPE html>
<html>
<head>
<style>
#flexbox {
  display: -webkit-flex;
}

#left {
  -webkit-flex: 1;
  background-color: yellow;
}

#content {
  -webkit-flex: 1;
  background-color: grey;
}
</style>
<script src="../../fast/repaint/resources/text-based-repaint.js"></script>
<script>
// This test makes sure that we repaint the right region of a flexbox when
// changing the flex values. Only the middle of the test page should be
// repainted. If the top of the test page (above the flexbox) is repainted,
// this test fails.

function setFlex(id, animationPercentage, start, end) {
  var flexValue = start + ((end - start) * animationPercentage);
  document.getElementById(id).style.webkitFlex = flexValue + " 0 0px";
}

function step(count) {
    var animationPercentage = count ? 1 : .9;
    setFlex("content", animationPercentage, 1, 5);

    if (!count) {
        // FIXME: we need a better way of waiting for layout/repainting to happen
        setTimeout(step.bind(null, 1), 1);
    } else if (window.testRunner) {
        finishRepaintTest();
    }
}

window.testIsAsync = true;
window.onload = runRepaintTest;

function repaintTest() {
    window.startTime = Date.now();
    // FIXME: we need a better way of waiting for layout/repainting to happen
    setTimeout(step.bind(null, 0), 1);
}
</script>
</head>
<body>
<br><br><br><br><br><br>
<div id="flexbox">
<div id="left"></div>
<div id="content">
<p style="margin: 0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean laoreet dolor id urna eleifend aliquet. Nulla vel dolor ipsum. Aliquam ut turpis nisl, in vulputate sapien. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed congue magna vitae dolor feugiat vehicula. Sed volutpat, tellus vel varius vestibulum, purus quam mollis sapien, in condimentum leo neque sed nulla. Nunc quis porta elit. Pellentesque erat lectus, ultricies a lobortis id, faucibus id quam.</p>
</div>
</body>
</html>
